package ar.com.cooker.model;

import java.io.Serializable;

import javax.persistence.Embeddable;
import javax.persistence.FetchType;
import javax.persistence.ManyToOne;
/**
 * Objeto integrable para ingrediente y receta.
 * @author c02536
 *
 */
@Embeddable
public class RecipeIngredientId implements Serializable{

	private static final long serialVersionUID = -6131107304804684751L;

	@ManyToOne(targetEntity = Ingredient.class, fetch = FetchType.LAZY)
	private Ingredient ingredient;

	@ManyToOne(targetEntity = IngredientType.class, fetch = FetchType.LAZY)
	private Recipe recipe;

	public RecipeIngredientId() {
	}

	public Ingredient getIngredient() {
		return ingredient;
	}

	public void setIngredient(Ingredient ingredient) {
		this.ingredient = ingredient;
	}

	public void setRecipe(Recipe recipe) {
		this.recipe = recipe;
	}
	
	public Recipe getRecipe() {
		return recipe;
	}

	public boolean equals(Object o) {
		if (this == o)
			return true;
		if (o == null || getClass() != o.getClass())
			return false;
		RecipeIngredientId that = (RecipeIngredientId) o;
		if ( ingredient != null ? !ingredient.equals(that.ingredient) : that.ingredient != null)
			return false;
		if (recipe != null ? !recipe.equals(that.recipe) : that.recipe != null)
			return false;
		return true;
	}

	public int hashCode() {
		int result;
		result = (ingredient != null ? ingredient.hashCode() : 0);
		result = 31 * result + (recipe != null ? recipe.hashCode() : 0);
		return result;
	}

	
}
